<extend name="common:wechatTemplate" />
<block name="main_content">
<style type="text/css">
.form-horizontal .controls {
    margin-left: 15px;
}
.form-horizontal .control-label {
    float: left;
    padding-top: 5px;
    text-align: left;
    width: 160px;
    margin-left: 15px;
}
</style>
<div id="content">
	<!-- 错误提示功能 -->
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i></span>
						<h5>{$vote_info.vote_name}</h5>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate"  action="#" method="post" class="form-horizontal">
							<div class="alert" style="margin-bottom: 0px">
								<a class="close" data-dismiss="alert" href="#">×</a> 
								<strong>友情提示:</strong>每人最多可投{$vote_info.check_box_max}票
							</div>
                           	<volist  name="vote_info['item_info']" id="item" >
                           		<div class="control-group">
									<div class="controls">
										<label>
											<span>
												<input name="vote_item" style="opacity: 0;" type="{$input_type}" value="{$item.item_id}">
											</span>{$item.item_name}
										</label>
									</div>
								</div>
							</volist >
							<div class="form-actions">
								<button id="btn_save" type="button" class="btn btn-large btn-info">提交</button>
							</div> 
						</form>
						
					</div>
					
				</div>
			</div>
		</div>
	</div>
</div>
</block>
<block name="js_content">
<script src="/Public/js/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript">
 VotePage = {
		'Bind' : function(){
			 $('#btn_save').bind('click', function(){
				var vote_id = "{$vote_info.vote_id}";
				var check_box_max = "{$vote_info.check_box_max}";
				var input_value = "{$input_type}";
				var checkItems = $('input:'+input_value+'[name=vote_item]:checked');
				if(checkItems.length == 0){
					alert("至少投一票");
					return;
				}
				if(checkItems.length > check_box_max){
					alert("最多可投"+check_box_max+"票");
					return;
				}
				var ids = new Array();
				$.each(checkItems, function(index, obj){
				  	ids.push($(obj).val());
				});
				var index = layer.load(1, {
				  shade: [0.5,'#CDCDB4']
				});  
				var params = 'user_id='+"{$user_id}"+'&user_name='+"{$user_name}"+'&vote_id='+vote_id + '&item_ids='+ids;
			    window.location.href = '/wechat/doVote?'+params;
				//layer.close(index);
				//alert("敬请期待");
			}); 
		}
	};	
	$(document).ready(function(){
		VotePage.Bind();
	}); 
</script>
</block>